import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/home',
      name:'home',
      component: () => import('../Home/index.vue')
    },
    {
      path: '/city',
      component: () => import('../City/index.vue')
    },
    {
      path:'/',
      redirect: '/home',
      
    }
  ]
})


router.beforeEach((to, from) => {
  if(to.path !== '/') {
    // 返回 false 以取消导航
    // return false
  }
  // console.log(to);//{fullPath: '/', path: '/', query: {…}, hash: '', name: undefined, …}
})
export default router